import { action, observable } from 'mobx-miniprogram'

export const store = observable({

    //后端服务地址
    programURL: 'http://localhost:8880',

    //tabBar共享数据
    activeTabBarIndex: 0,
    updateActiveTabBarIndex: action(function(index) {
        this.activeTabBarIndex = index
    }),

    //文章详情共享数据
    articleDto:{},
    updateArticleDto: action(function(dto) {
        this.articleDto = dto
    }),

    //登录凭证token
    token: null,
    updateToken: action(function(token) {
        this.token = token
    }),

    //用户聊天共享数据
    chatDto: {},
    updateChatDto: action(function(dto) {
        this.chatDto = dto
    }),

    //当前用户数据
    userInfo: {},
    updateUserInfo: action(function(user) {
        this.userInfo = user
    }),
    updateUserName: action(function(name) {
        this.userInfo.nickname = name
    }),
    updateUserAvatar: action(function(url) {
        this.userInfo.avatarUrl = url
    }),

})